package com.zlq.cn.dto.param;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import org.springframework.util.Assert;

import javax.validation.constraints.NotNull;

@Getter
@Setter
public class PageParam {

    @ApiModelProperty(value = "当前页码", required = true)
    @NotNull(message = "当前页码不能为空")
    private Long current;

    @ApiModelProperty(value = "每页大小", required = true)
    @NotNull(message = "每页大小不能为空")
    private Long size;

    public <T> Page<T> getPage() {
        Assert.notNull(current,"当前页码不能为空");
        Assert.notNull(size,"每页大小不能为空");
        return new Page<>(current, size);
    }
}
